class Plotter {
  ArrayList<PVector> notesList;
  ArrayList<PVector> durationsList;
  ArrayList<PVector> velocityesList;

  Plotter() {
    notesList = new ArrayList<PVector>();
    durationsList = new ArrayList<PVector>();
    velocityesList = new ArrayList<PVector>();
  }

  void plot() {
    //background(255);
    stroke(0);
    text("Notes graph", 20, 290);
    drawNotesGraph(20, 300);
    text("Durations graph", 20, 420);
    drawDurationsGraph(20, 430);
    text("Velocities graph", 20, 500);
    drawVelocitiesGraph(20, 510);
  }

  void drawNotesGraph(int x, int y) {
    int w = width-40;
    int h = 100;
    stroke(40);
    fill(150, 150, 160);
    rect(x, y, w, h);
    pushMatrix();
    translate(x, y);

    //notesList
    for (int i = 0; i < notesList.size(); i++) {
      stroke(20, 80, 125);
      float val = notesList.get(i).x/10;
      float val2 = notesList.get(i).y/5;

      val = map(val, 0, notesList.size(), 5, w-5);
      val2 = map(val2, 0, 128, 5, h-5);
      point(val, val2);

      if (i < notesList.size()-2) {
        float val3 = notesList.get(i+1).x/10;
        float val4 = notesList.get(i+1).y/5;

        val3 = map(val3, 0, notesList.size(), 5, w-5);
        val4 = map(val4, 0, 128, 5, h-5);
        line(val3, val4, val, val2);
      }
    }
    popMatrix();
  }

  void drawDurationsGraph(int x, int y) {
    int w = width-40;
    int h = 50;
    stroke(40);
    fill(150, 150, 160);
    rect(x, y, w, h);
    pushMatrix();
    translate(x, y);

    //notesList
    for (int i = 0; i < durationsList.size(); i++) {
      stroke(40, 100, 125);
      float val = durationsList.get(i).x/10;
      float val2 = durationsList.get(i).y/5;

      val = map(val, 0, durationsList.size(), 5, w-5);
      val2 = map(val2, 1, 7, 5, h-5);
      point(val, val2);

      if (i < durationsList.size()-2) {
        float val3 = durationsList.get(i+1).x/10;
        float val4 = durationsList.get(i+1).y/5;

        val3 = map(val3, 0, durationsList.size(), 5, w-5);
        val4 = map(val4, 1, 7, 5, h-5);
        line(val3, val4, val, val2);
      }
    }
    popMatrix();
  }

  void drawVelocitiesGraph(int x, int y) {
    int w = width-40;
    int h = 100;
    stroke(40);
    fill(150, 150, 160);
    rect(x, y, w, h);
    pushMatrix();
    translate(x, y);

    //notesList
    for (int i = 0; i < velocityesList.size(); i++) {
      stroke(20, 40, 125);
      float val = velocityesList.get(i).x/10;
      float val2 = velocityesList.get(i).y/5;

      val = map(val, 0, velocityesList.size(), 5, w-5);
      val2 = map(val2, 0, 127, 5, h-5);
      point(val, val2);

      if (i < notesList.size()-2) {
        float val3 = velocityesList.get(i+1).x/10;
        float val4 = velocityesList.get(i+1).y/5;

        val3 = map(val3, 0, velocityesList.size(), 5, w-5);
        val4 = map(val4, 0, 127, 5, h-5);
        line(val3, val4, val, val2);
      }
    }
    popMatrix();
  }
}

